Skip to content

test: migrate math/base/special/factorial2f to ULP-based assertions - #14364

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-factorial2f
Draft

test: migrate math/base/special/factorial2f to ULP-based assertions#14364
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-factorial2f

Conversation

@kgryte

@kgryte kgryte commented Aug 18, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the test suites for math/base/special/factorial2f from relative tolerance assertions to ULP difference assertions, as described in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol computation (previously 2.4 * EPS * absf( expected[i] )) and the associated t.ok( delta <= tol, ... ) / exact-equality branch with a single t.strictEqual( isAlmostSameValue( v, expected[ i ], 3 ), true, 'returns expected value' ) assertion.
  • adds a require for @stdlib/number/float32/base/assert/is-almost-same-value (the single-precision variant, as factorial2f operates on single-precision values) and removes the now unused @stdlib/math/base/special/absf and @stdlib/constants/float32/eps requires.

The same change is applied to both test/test.js and test/test.native.js.

ULP bound: 3 ULP, for the "the function evaluates the double factorial" test in both test/test.js and test/test.native.js. This is the measured minimum over the full fixture set (56 values, test/fixtures/python/data.json); the observed ULP difference distribution is {0: 32, 1: 20, 2: 2, 3: 2}, with the maximum occurring at x = 47. Lowering the bound to 2 causes 2 test cases to fail, so 3 is the tightest bound which passes. The suite was run twice at the final bound to confirm the result is deterministic.

Only the two test files are changed; no source, documentation, or fixture files were touched.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

  • test/test.native.js is skipped locally, as the native add-on was not built in this environment. The ULP bound in test/test.native.js mirrors the bound measured for the JavaScript implementation, consistent with prior conversions in this family (e.g., math/base/special/cphasef, math/base/special/gammaln).
  • The existing NOTE explaining why approximate equality is used for these fixtures (SciPy computes the expected values via gamma function approximations rather than iterative single-precision computation) has been retained, as it remains applicable.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code, running as an automated task. The ULP bound was determined empirically by measuring the ULP difference across the full fixture set and verifying that the next lower bound fails.


@stdlib-js/reviewers


Generated by Claude Code

Ref: #11352

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 18, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/factorial2f $\\color{green}200/200$
$\\color{green}+100.00\\%$
$\\color{green}17/17$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}200/200$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants